import datetime
from django.db import models
from django.db.models import permalink
from django.utils.translation import ugettext_lazy as _

MENU = ((1, _('top menu')),
        (2, _('side-bar')))

class Page(models.Model):
    menu = models.IntegerField(choices=MENU)
    position = models.IntegerField(editable=False, default=0)
    title = models.CharField(_('title'), max_length=100)
    slug = models.SlugField(_('slug'), unique=True)
    description = models.TextField(blank=True)
    content = models.TextField()
    template = models.CharField(_('template name'), max_length=100, blank=True)

    class Meta:
        verbose_name = _('page')
        verbose_name_plural = _('pages')
        ordering = ('title',)
    
    def __unicode__(self):
        return self.title

    @permalink
    def get_absolute_url(self):
        return ("page", (), {'slug': self.slug})
